# SYNTAX TEST "Packages/PackageDev/Package/Sublime Text Syntax Definition/Oniguruma RegExp.sublime-syntax"


###################
## Anchors and escapes
###################

^foo \bbar$
# <- keyword.control.anchors
#    ^^ keyword.control.anchors
#         ^ keyword.control.anchors

\^foo \\bbar\$
 # <- constant.character.escape
#     ^^ constant.character.escape
#            ^ constant.character.escape

\xg
# <- invalid.illegal.character.escape

\010
# <- constant.character.escape

\1
# <- keyword.other.backref-and-recursion
#^ variable.other.backref-and-recursion.regexp

\xab
# <- constant.character.escape
#^^^ constant.character.escape

 \x{712fe672}\x{9}
#^^^^^^^^^^^^^^^^^ constant.character.escape

\w\W\s\S\d\D\h\H \.
# <- support.class.character-class
#^^^^^^^^^^^^^^^ support.class.character-class
#                ^^ constant.character.escape - keyword.control.character-class

\p{Print}\p{^Alpha}\P{C}\P{Katakana}
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ keyword.other.character-class.property.regexp
# ^ punctuation.definition.property.begin
#  ^^^^^ support.type.property.regexp
#       ^ punctuation.definition.property.end
#            ^^^^^ support.type.property.regexp
#                     ^ support.type.property.regexp
#                         ^ punctuation.definition.property.begin
#                                  ^ punctuation.definition.property.end
#                          ^^^^^^^^ support.function.property.untested.regexp


###################
## Quantifiers
###################

\x00*
# <- constant.character.escape
#^^^ constant.character.escape
#   ^ keyword.operator.quantifier

(ab)+
#   ^ keyword.operator.quantifier

(ab)?
#   ^ keyword.operator.quantifier

(ab)*?
#   ^^ keyword.operator.quantifier

(ab)*+
#   ^^ keyword.operator.quantifier

(ab)+?
#   ^^ keyword.operator.quantifier

(ab)++
#   ^^ keyword.operator.quantifier

(?abc)
#^ invalid.illegal.unexpected-quantifier.regexp - storage.modifier.mode.regexp
# ^^^ meta.literal.regexp - storage.modifier.mode.regexp

 .*?
#^ keyword.other.any.regexp - meta.literal.regexp
# ^^ keyword.operator.quantifier.regexp

(?=.++\.??\|{2,3}|{2})
#^^ constant.other.assertion.regexp
#  ^ keyword.other.any.regexp - meta.literal.regexp
#   ^^ keyword.operator.quantifier.regexp
#     ^^ constant.character.escape.regexp
#       ^^ keyword.operator.quantifier.regexp
#         ^^ constant.character.escape.regexp
#           ^^^^^ keyword.operator.quantifier.regexp
#                 ^^^ invalid.illegal.unexpected-quantifier.regexp - keyword.operator.quantifier.regexp

\G{2}
# ^^^ invalid.illegal.unexpected-quantifier.regexp - keyword.operator.quantifier.regexp

(?={2})
#  ^^^ invalid.illegal.unexpected-quantifier.regexp - keyword.operator.quantifier.regexp

a{9}
#^^^ keyword.operator.quantifier.regexp

a{1,9}
#^^^^^ keyword.operator.quantifier.regexp

a{9,}
#^^^^ keyword.operator.quantifier.regexp

a{,9}
#^^^^ keyword.operator.quantifier.regexp

a{,}
#^^^ - keyword.operator.quantifier.regexp

a{}
#^^ - keyword.operator.quantifier.regexp

|{1,2}
#^^^^^ invalid.illegal.unexpected-quantifier.regexp

hello**
#     ^ invalid.illegal.unexpected-quantifier.regexp
#<- meta.literal.regexp
#^^^^ meta.literal.regexp

)
# <- invalid.illegal.unmatched-brace.regexp

hello++
#    ^^ keyword.operator.quantifier.regexp - invalid.illegal.unexpected-quantifier.regexp

(\w{2}?)
#  ^^^^ keyword.operator.quantifier.regexp

(\w{2}+)
#     ^ invalid.illegal.unexpected-quantifier.regexp

(\w{2}?+)
#  ^^^^ keyword.operator.quantifier.regexp
#      ^ invalid.illegal.unexpected-quantifier.regexp

[\w{1}+]
#  ^^^^ - invalid.illegal.unexpected-quantifier.regexp - keyword.operator.quantifier.regexp


###################
## Sets
###################

 [b-c]
#^^^^^ meta.set
#^ keyword.control.set
#    ^ keyword.control.set
# ^^^ constant.other.range

[\x00-\x0A]
# <- keyword.control.set
#         ^ keyword.control.set
#^^^^^^^^^ constant.other.range
#^^^^ constant.character.escape
#     ^^^^ constant.character.escape

[[a-z]&&[:ascii:]]
#^^^^^ meta.set meta.set
#     ^^ keyword.operator.intersection
# ^^^ constant.other.range
# ^^^ - constant.other.range constant.other.range
#        ^^^^^^^ constant.other.posix-class

[^abc\w0-9]
# <- keyword.control.set
#^ keyword.control.set
#    ^^ support.class.character-class

[a-c-x]
#^^^ constant.other.range
#   ^^ - constant.other.range

[[-\w]abc]
#^^^^^ meta.set.regexp meta.set.regexp
#        ^ keyword.control.set.regexp

[]-]
#  ^ keyword.control.set
# ^ - constant.other.range

[-a-n]
#    ^ keyword.control.set
#^ - constant.other.range
# ^^^ constant.other.range

[\-a]
#^^^ - constant.other.range
#   ^ keyword.control.set

[a-z\-9]
#   ^^^ - constant.other.range
#      ^ keyword.control.set

[\--z]
#^^^^ constant.other.range
#    ^ keyword.control.set

[a-\z]
#^^^^ constant.other.range
#    ^ keyword.control.set

[a-\-]
#^^^^ constant.other.range
#    ^ keyword.control.set

(?:a|b|c)
#^^^^^^^^ meta.group
# <- keyword.control.group punctuation.section.group.begin.oniguruma
#^^ constant.other.assertion
#   ^ keyword.operator
#       ^ keyword.control.group punctuation.section.group.end.oniguruma


###################
## Block comments
###################

(?#foobar)
#^^^^^^^^^ meta.group comment.block.group
# <- comment.block.group punctuation.definition.comment.begin
#^^ punctuation.definition.comment.begin
#        ^ punctuation.definition.comment.end

( abc (?#foobar) )
#     ^^^^^^^^^^ meta.group meta.group comment.block.group

(?#

this is a multi line comment
where escape characters are ignored.\).
#<- comment.block.group
#                                   ^^ - constant.character.escape
#                                    ^ punctuation.definition.comment.end.regexp
#                                     ^ - comment.block.group.regexp


###################
## Group Modifiers & Extended Mode
###################

(?x)
#^^ storage.modifier.mode.regexp
#   ^ meta.ignored-whitespace

# this is a comment
#^^^^^^^^^^^^^^^^^^^ comment.line.number-sign
# <- comment punctuation.definition.comment
 (?-ix)
# <- meta.ignored-whitespace
# ^^^^ storage.modifier.mode.regexp

# not a comment
# <- - comment

(
    (?x)
    # comment
#   ^^^^^^^^^ comment
   (?-x)
) # no comment
# <- keyword.control.group punctuation.section.group.end.oniguruma
# ^ - comment

(?sm-ixxs)
#^^^^^^^^ storage.modifier.mode.regexp

 (?i:hello)
#^^^^^^^^^^ meta.group.regexp
#^ keyword.control.group.regexp punctuation.section.group.begin.oniguruma
# ^^^ storage.modifier.mode.regexp
#    ^ - storage.modifier.mode.regexp
#         ^ keyword.control.group.regexp punctuation.section.group.end.oniguruma

 (?i-s:hello)
#^^^^^^^^^^^^ meta.group.regexp
#^ keyword.control.group.regexp punctuation.section.group.begin.oniguruma
# ^^^^^ storage.modifier.mode.regexp
#      ^ - storage.modifier.mode.regexp
#           ^ keyword.control.group.regexp punctuation.section.group.end.oniguruma

# not a comment
^ - comment

(?ix:
#^^^^
# comment
#^^^^^^^^ comment.line.number-sign

    (# also a comment)
#    ^^^^^^^^^^^^^^^^^ comment
    )

 (?s-x: # not a comment)
#       ^ - comment

)
# not a comment
^ - comment

(?x:[ ] )
#    ^ - meta.ignored-whitespace.regexp
#      ^ meta.ignored-whitespace.regexp

###################
## References
###################

(?<named_group>test)
#^^^^^^^^^^^^^^ keyword.other.named-capture-group.regexp
#  ^^^^^^^^^^^ entity.name.capture-group.regexp
#              ^^^^ meta.literal.regexp - keyword.other.named-capture-group.regexp

 \g'named_group'
#^^^^^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#   ^^^^^^^^^^^ variable.other.backref-and-recursion.regexp
#  ^ punctuation.definition.backref.begin.regexp
#              ^ punctuation.definition.backref.end.regexp

 \g<named_group>
#^^^^^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#   ^^^^^^^^^^^ variable.other.backref-and-recursion.regexp
#  ^ punctuation.definition.backref.begin.regexp
#              ^ punctuation.definition.backref.end.regexp

(?x)(?<named_group>test)\g<named_group>(?-x)
#   ^^^^^^^^^^^^^^^^^^^^ meta.group.extended
#    ^^^^^^^^^^^^^^ keyword.other.named-capture-group.regexp
#      ^^^^^^^^^^^ entity.name.capture-group.regexp
#     ^ punctuation.definition.capture-group-name.begin.regexp
#                 ^ punctuation.definition.capture-group-name.end.regexp
#                  ^^^^ meta.literal.regexp - keyword.other.named-capture-group.regexp
#                        ^^^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                          ^^^^^^^^^^^ variable.other.backref-and-recursion.regexp
#                         ^ punctuation.definition.backref.begin.regexp
#                                     ^ punctuation.definition.backref.end.regexp

\k'named_group+1'
#^^^^^^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#  ^^^^^^^^^^^ variable.other.backref-and-recursion.regexp
#             ^^ constant.numeric.backref-level.regexp
# ^ punctuation.definition.backref.begin.regexp
#               ^ punctuation.definition.backref.end.regexp
(?:\k'named_group+1'|\k<213-1>)
#  ^^^^^^^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                ^^ constant.numeric.backref-level.regexp
#    ^ punctuation.definition.backref.begin.regexp
#                  ^ punctuation.definition.backref.end.regexp
#                    ^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                          ^^ constant.numeric.backref-level.regexp
#                      ^ punctuation.definition.backref.begin.regexp
#                            ^ punctuation.definition.backref.end.regexp

###################
## Assertions
###################

(?![a-z]+?)
#^^ meta.group.regexp constant.other.assertion.regexp - meta.group.regexp meta.group.regexp
#  ^^^^^ meta.set.regexp
#  ^ keyword.control.set.regexp
#      ^ keyword.control.set.regexp
#   ^^^ constant.other.range.regexp
#       ^^ keyword.operator.quantifier.regexp

(?![abc].\g'1'(?m)$)[\g'1']
#^^ constant.other.assertion.regexp
#  ^ keyword.control.set.regexp
#      ^ keyword.control.set.regexp
#   ^^^ - meta.literal.regexp
#       ^ keyword.other.any.regexp
#        ^^^^^ keyword.other.backref-and-recursion.regexp
#          ^ punctuation.definition.backref.begin.regexp
#           ^ variable.other.backref-and-recursion.regexp
#            ^ punctuation.definition.backref.end.regexp
#              ^^ meta.group.regexp meta.group.regexp storage.modifier.mode.regexp
#                 ^ keyword.control.anchors.regexp
#                    ^^ constant.character.escape.regexp
#                    ^^^^^ - keyword.other.backref-and-recursion.regexp

(?<=blah)
#^^^ constant.other.assertion.regexp
(?<!\w+\(\))
#^^^ constant.other.assertion.regexp
(?>\[\d+\])
#^^ constant.other.assertion.regexp
#  ^^ constant.character.escape.regexp - keyword.control.set.regexp
#    ^^ support.class.character-class.regexp
#      ^ keyword.operator.quantifier.regexp
#       ^^ constant.character.escape.regexp - keyword.control.set.regexp


###################
## Lots of things
###################

(?x)
(?<element> \g<stag> \g<content>* \g<etag> ){0}
# <- meta.group.extended keyword.control.group punctuation.section.group.begin.oniguruma
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.extended
#^^^^^^^^^^ keyword.other.named-capture-group.regexp
#  ^^^^^^^ entity.name.capture-group.regexp
#          ^ meta.ignored-whitespace.regexp
#           ^^^^^^^^ keyword.other.backref-and-recursion.regexp
#              ^^^^ variable.other.backref-and-recursion.regexp
#                   ^ meta.ignored-whitespace.regexp
#                    ^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                       ^^^^^^^ variable.other.backref-and-recursion.regexp
#                               ^ keyword.operator.quantifier.regexp
#                                ^ meta.ignored-whitespace.regexp
#                                 ^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                                    ^^^^ variable.other.backref-and-recursion.regexp
#                                         ^ meta.ignored-whitespace.regexp
#                                          ^ keyword.control.group punctuation.section.group.end.oniguruma
#                                           ^^^ keyword.operator.quantifier.regexp
#                                              ^ meta.ignored-whitespace.regexp
(?<stag> < \g<name> \s* > ){0}
# <- meta.group.extended keyword.control.group punctuation.section.group.begin.oniguruma
#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.extended
#^^^^^^^ keyword.other.named-capture-group.regexp
#       ^ meta.ignored-whitespace.regexp
#        ^ meta.literal.regexp
#         ^ meta.ignored-whitespace.regexp
#           ^^^^^^^ keyword.other.backref-and-recursion.regexp
#                  ^ meta.ignored-whitespace.regexp
#                   ^^ support.class.character-class
#                     ^ keyword.operator.quantifier
#                      ^ meta.ignored-whitespace.regexp
#                       ^ meta.literal.regexp
#                        ^ meta.ignored-whitespace.regexp
#                         ^ keyword.control.group punctuation.section.group.end.oniguruma
#                          ^^^ keyword.operator.quantifier.regexp
(?<name> [a-zA-Z_:]+ ){0}
# <- meta.group.extended keyword.control.group
#^^^^^^^^^^^^^^^^^^^^^ meta.group.extended
#^^^^^^^ keyword.other.named-capture-group.regexp
#       ^ meta.ignored-whitespace.regexp
#        ^^^^^^^^^^ meta.set
#        ^ keyword.control.set
#         ^^^^^^ constant.other.range
#                 ^ keyword.control.set
#                  ^ keyword.operator.quantifier
#                   ^ meta.ignored-whitespace.regexp
#                    ^ keyword.control.group punctuation.section.group.end.oniguruma
#                     ^^^ keyword.operator.quantifier.regexp
(?<content> [^<&]+ (\g<element> | [^<&]+)* ){0}
# <- meta.group.extended keyword.control.group punctuation.section.group.begin.oniguruma
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.extended
#^^^^^^^^^^ keyword.other.named-capture-group.regexp
#           ^^^^^ meta.set
#           ^^ keyword.control.set
#                ^ keyword.operator.quantifier
#                 ^ meta.ignored-whitespace.regexp
#                  ^^^^^^^^^^^^^^^^^^^^^^ meta.group.extended meta.group.extended
#                  ^ keyword.control.group punctuation.section.group.begin.oniguruma
#                   ^^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                              ^ meta.ignored-whitespace.regexp
#                               ^ keyword.operator.alternation
#                                ^ meta.ignored-whitespace.regexp
#                                 ^^^^^ meta.set
#                                      ^ keyword.operator.quantifier
#                                       ^ keyword.control.group punctuation.section.group.end.oniguruma
#                                        ^ keyword.operator.quantifier
#                                         ^ meta.ignored-whitespace.regexp
#                                          ^ keyword.control.group punctuation.section.group.end.oniguruma
#                                           ^^^ keyword.operator.quantifier.regexp
(?'etag' </ \k<name+1> > ){0}
# <- meta.group.extended keyword.control.group punctuation.section.group.begin.oniguruma
#^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.extended
#^^^^^^^ keyword.other.named-capture-group.regexp
#       ^ meta.ignored-whitespace.regexp
#        ^^ meta.literal.regexp
#          ^ meta.ignored-whitespace.regexp
#           ^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#                  ^^ constant.numeric.backref-level
#                     ^ meta.ignored-whitespace.regexp
#                      ^ meta.literal.regexp
#                       ^ meta.ignored-whitespace.regexp
#                        ^ keyword.control.group punctuation.section.group.end.oniguruma
#                         ^^^ keyword.operator.quantifier.regexp
\g<element>
#^^^^^^^^^^ keyword.other.backref-and-recursion.regexp
#   ^^^^^^ variable.other.backref-and-recursion.regexp
(?-x)

check if all scopes are cleared:
# <- meta.literal - meta meta

# <- - meta
